﻿var ukCrossChargeType = newValue;
var expenseType = ref.ExpenseType.getValue();
var viewStatus = this.lookupController().analysis().status;

ref.BrandAllocationCJLR.setHidden(ukCrossChargeType == 'JLRCUK');

switch (ukCrossChargeType) {
    case 'JLRCUK':
        ref.UKGLCode.show();
        ref.UKCostCenter.show();
        ref.ukCrossChargeAttachments.show();

        ref.CompanyAllocation.hide();

        if (self.containsFocus) {
            ref.UKGLCode.setAllowBlank(false);
            ref.UKCostCenter.setAllowBlank(false);
        }
        break;
    case 'UKJLRC':
        ref.UKGLCode.hide();
        ref.UKCostCenter.hide();
        ref.ukCrossChargeAttachments.show();
        ref.CompanyAllocation.show();

        if (self.containsFocus) {
            ref.UKGLCode.setValue('');
            ref.UKCostCenter.setValue('');
            ref.file7.store.removeAll();
        }
        var grid3 = ref.datagrid3,
            editor3 = grid3.getColumns()[2].getEditor;
        if (editor3) {
            editor3 = grid3.getColumns()[2].getEditor();
            editor3.getStore().loadData([
                { name: "JLRC", code: "JLRC" },
                { name: "CJLR", code: "CJLR" }
            ]);
        }
        break;
    case 'No':
        ref.UKGLCode.hide();
        ref.UKCostCenter.hide();
        ref.ukCrossChargeAttachments.hide();
        ref.CompanyAllocation.show();

        var grid3 = ref.datagrid3,
            editor3 = grid3.getColumns()[2].getEditor;
        if (editor3) {
            editor3 = grid3.getColumns()[2].getEditor();
            editor3.getStore().loadData([
                { name: "JLRC", code: "JLRC" },
                { name: "CJLR", code: "CJLR" },
                { name: "LRE", code: "LRE" }
            ]);
        }
        break;
    default:
}

ref.SharingPrinciple.setHidden(ukCrossChargeType != 'No');
ref.companySharingRatioTips.setHidden(ukCrossChargeType != 'No');

var company = ref.companyC.getValue();

if (company == 'LRE') {
    //品牌分摊字表最终判断.如果公司是LRE.就隐藏.
    ref.BrandAllocationJLRC.hide();
    ref.BrandAllocationCJLR.hide();
    ref.SharingPrinciple.hide();
    ref.companySharingRatioTips.hide();
    ref.costCategory.hide();
    ref.costCategory.setValue('');
}

if (self.containsFocus) {
    ref.datagrid2.store.removeAll();

    ref.datagrid3.store.removeAll();
    ref.datagrid4.store.removeAll();
    ref.datagrid5.store.removeAll();

    ref.datagrid3.getColumns()[0].getEditor().store.data.removeAll();
    ref.datagrid4.getColumns()[0].getEditor().store.data.removeAll();
    ref.datagrid5.getColumns()[0].getEditor().store.data.removeAll();
}